import search.*;
import java.util.*;
/**
 * This represents the cities and roads between them.
 * It represents the state space.
 * 
 * @author Thomas Kingston 
 * 
 */
public class TourFinder extends DepthFirstSearchVisitor<TourState,TourEdge>
{
	private CityMap map;
	private TourState start;
	private TourState goal;
	    
	
    /**
     * Constructor for objects of class TourFinder
     */
	public TourFinder(CityMap map, String startCityName, String endCityName)
	{
		this.map = map;
		start = findTourState(startCityName);
		goal = findTourState(endCityName);
	}
   /** 
     * Find a city node in this state space based on the name of the city it represents.
     * @param cityName The name of the city to find a city for.
     * @return The city node representing this city, or null if there isn't one. 
     */
    public TourState findTourState(String cityName)
    {
        
    	for (City node: map.getNodes())
        {
            if (node.getData().equals(cityName))
            {
            	Tour t = new Tour();
            	t.addCity(node);
                return new TourState(t);
            }
        }
        return null;
    }
    public TourState getStart() 
    { 	
    	return start;
    }
    public boolean isGoal(TourState state) 
    {
    	return (state.equals(goal));
    }
}